// pages/paysuccess/paysuccess.js
import {
  ajax,
  src,
  util
} from "../../utils/util.js";
Page({

  /**
   * 页面的初始数据
   */



  data: {
    fangbian:0,
    qingjie:0,
    tiyan:0,
    orderid:""
  },

  getScore(e) {
    console.log("被评价的object：", e.detail.rateObj, "评分：", e.detail.value);
    if (e.detail.rateObj=="0"){
      this.setData({
        fangbian: e.detail.value
      })
    }
    if (e.detail.rateObj == "1") {
      this.setData({
        qingjie: e.detail.value
      })
    }
    if (e.detail.rateObj == "2") {
      this.setData({
        tiyan: e.detail.value
      })
    }

  },


  phoneCall: function (e) {
    var tel = e.currentTarget.dataset.tel;

    if (wx.getStorageSync('uqid')) {
      ajax("/api/user/service", {
        data: {
          uqid: this.data.uqid,
        },
        header: {
          'Accept': 'application/json', // 默认值
        },
        method: 'get'
      }, res => {
        console.log(res);
        if (res.error == 0) {
          this.setData({
            kftel: res.data.admin_phone
          })
          wx.makePhoneCall({
            phoneNumber: res.data.admin_phone //仅为示例，并非真实的电话号码
          })
        }
      })
    } else {
      wx.showToast({
        title: '请先授权！',
        icon: 'none',
        duration: 2000
      })

    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var orderid=options.orderid
    var uqid = wx.getStorageSync("uqid")
    this.setData({
      orderid:orderid,
      uqid:uqid
    })
  },
  tomyorder:function(){

    ajax("/api/scan/evaluation", {
      data: {
        uqid: this.data.uqid,
        order_id: this.data.orderid,
        convenience: this.data.fangbian,
        clean: this.data.qingjie,
        learn:this.data.tiyan
      },
      header: {
        'Accept': 'application/json', // 默认值
      },
      method: 'post'
    }, res => {
      console.log(res);
      if (res.error == 0) {
        wx.navigateTo({
          url: '/pages/myorder/myorder',
        })
      }
    })

   
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})